<include file="Public/header"/>
<include file="Public/menu"/>
<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            {$title}
            <small>{$title_two}</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> {$title}</a></li>
            <li class="active">{$title_two}</li>
        </ol>
    </section>
    <!-- 内容 -->
    <section class="content">

        <div class="tab-content">
            <div class="tab-pane active" id="tab_0">
                <div class="box">
                    <div class="box-header">
                        <h3 class="box-title"></h3>
                        <div class="form-inline pull-right">
                            <form action="{:U('Flashsales/index')}" method="get" onSubmit="return checkSubmit();">
                                <fieldset>
                                    <div class="input-group input-group-sm" id="rushTime">
                                        <label class="input-group-addon col-xm-4"><strong>限时抢购日期</strong></label>
                                        <div class="col-sm-12 input-group-sm" style="padding: 0;">
                                            <input type="text" class="col-xm-6 form-control" style="border-radius: 0;" id="begintime" name="begintime" value="{$begintime}">
                                            <span class="col-xm-1 form-control" style="padding: 5px; border: none;">--</span>
                                            <input type="text" class="col-xm-6 form-control" id="endtime" name="endtime" value="{$endtime}">
                                        </div>
                                    </div>
                                    <!--<div class="input-group input-group-sm" style="margin-right: 20px">
                                        <span class="input-group-addon"><strong>姓名</strong>
                                        </span>
                                        <input type="text" class="form-control" placeholder="姓名" name="name" value="{$name}">
                                    </div>-->
                                    <select class="form-control" name="select" style="height: 30px; font-size: 12px;">
                                        <option value="id" <if condition="$select eq 'id' "> selected = "selected"</if>>ID</option>
                                        <option value="name" <if condition="$select eq 'name' "> selected = "selected"</if>>规则名称</option>
                                    </select>
                                    <div class="input-group input-group-sm">
                                        <div class="input-group input-group-sm">
                                            <input type="text" class="form-control" placeholder="" name="value" value="{$value}">
                                        </div>
                                    </div>

                                    <div class="input-group input-group-sm">
                                        <div class="input-group-btn">
                                            <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i>
                                            </button>
                                        </div>
                                    </div>
                                </fieldset>
                            </form>
                        </div>

                        <!-- <div class="btn-group pull-right" style="margin-right: 10px">
                             <a href="/Qgs/sakila/actors?_pjax=%23pjax-container&amp;_export=1" target="_blank"
                                class="btn btn-sm btn-warning"><i class="fa fa-download"></i>&nbsp;&nbsp;Export</a>
                         </div>-->

                        <div class="btn-group pull-right" style="margin-right: 10px">
                             <a href="{:U('Flashsales/addFlashsales')}" class="btn btn-sm btn-success"><i
                                     class="fa fa-save"></i>&nbsp;&nbsp;新增一个限时抢购</a>
                         </div>

                    </div>
                    <div class="text-danger" style="line-height: 1.8; padding: 7px; font-size: 14px;border-top:1px solid #f4f4f4; ">提示：请复制链接【Flashsales/main】 到 【首页管理】-【图标栏目管理】</div>
                    <!-- /.box-header -->
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-hover">
                            <tbody>
                            <tr>
                                <th><input type="checkbox" class="grid-select-all"></th>
                                <th>ID<a id="a_order" rank='{$rank}' onclick="rankId('id','{$rank}')" class="fa fa-fw fa-sort" href="javascript:void(0);"></a>
                                </th>
                                <th>规则名称</th>
                                <th>限时抢购日期</th>
                                <th>发布时间</th>
                                <th>规则描述</th>
                                <th>时间段</th>
                                <th>操作</th>
                            </tr>
                            <foreach name="list" item="vo" >
                                <tr>
                                    <td><input type="checkbox" class="grid-item" data-id="{$vo.special_id}"></td>
                                    <td>{$vo.special_id}</td>
                                    <td>{$vo.name}</td>
                                    <td>{$vo.flashsales_date}</td>
                                    <td>{$vo.create_time|date='Y-m-d H:i:s',###}</td>
                                    <td>{$vo.description}</td>
                                    <td>
                                        <a href="{:U('Flashsales/timeIndex',['special_id'=>$vo[special_id]])}">查看时间段</a>
                                    </td>
                                    <td>
                                        <a href="{:U('Flashsales/saveFlashsales',['special_id'=>$vo[special_id]])}"><i class="fa fa-edit"></i></a>
                                        <if condition="$vo['is_start'] eq '1'">
                                            <a onclick="issure('{$vo[special_id]}')"  href="javascript:;"  class="btn btn-sm btn-warning order_goods" style="margin-left: 15px;">&nbsp;&nbsp;作废</a>
                                            <else/>
                                            <a href="javascript:;"  class="btn btn-sm btn-warning order_goods" style="margin-left: 15px;">&nbsp;&nbsp;已作废</a>
                                        </if>
                                    </td>
                                </tr>
                            </foreach>

                            </tbody>
                        </table>
                    </div>
                    <div class="box-footer clearfix">
                        <!--<input type="checkbox" class="grid-select-all">&nbsp;&nbsp;&nbsp;
                        <a class="btn btn-sm btn-danger batch-delete">Batch delete</a>-->
                        {$page}
                    </div>
                    <!-- /.box-body -->
                </div>
            </div>

        </div>
    </section>
</div>
<!-- 底部 -->
<include file="Public/common_footer"/>
<link rel="stylesheet" href="/Public/admin/jedate/jedate.css" />
<script src="/Public/admin/jedate/jedate.js"></script>
<script type="text/javascript">
    function issure($id) {
        if(confirm('确定要作废该抢购吗？')){
            window.location.href="/Admin/Flashsales/changeStart/is_start/0/special_id/"+$id+".html";
        }
    }
    // 设置时间
    function setJedate(){
        var start = {
            dateCell: '#begintime',
            format: 'YYYY-MM-DD',
            minDate: '1970-01-01 00:00:00',
            festival: false,
            maxDate: '2099-12-31 23:59:59',
            isinitVal:false,
            isTime: false,
            choosefun: function(datas) {
                end.minDate = datas; 
            }
        };
        var end = {
            dateCell: '#endtime',
            format: 'YYYY-MM-DD',
            minDate: '1970-01-01 00:00:00',
            festival: false,
            maxDate: '2099-12-31 23:59:59',
            isinitVal:false,
            isTime: false,
            choosefun: function(datas) {
                start.maxDate = datas;
            }
        };
        jeDate(start);
        jeDate(end);
    }
    setJedate();
    var rankId = function(ran,order){
        window.location.href="{:U('Flashsales/index')}"+"?begintime={$begintime}&endtime={$endtime}&select={$select}&value={$value}&"+ran+"="+order;
    }
    //冻结（解冻）
    var freezeMember = function(id,stat){
        if( (stat == 1) ? confirm('您确定要冻结该会员？') : confirm('您确定要解冻该会员？') ){
            $.post("{:U('User/freezeMember')}", { "id": id,"status": stat },
                    function(data){
                        if(data.stat){
                            alert(data.msg);
                            window.location.reload();
                        }else{
                            alert(data.msg);
                        }
                    }, "json");
        }
    }
	// 检查submit的数据
	function checkSubmit(){
		return true;	
	}
</script>

